from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
import unittest
from ui_auto.config .config import *
from ui_auto.public.utils.read_ini import Read_ini
from ui_auto.public.pages.basepage import BasePage
from ui_auto.data.page_elem import Analysysdata_elem
from selenium.webdriver.support.wait import WebDriverWait

#预备数据
file=os.path.join(data_path,"data.ini")
r=Read_ini(file)
url=r.read_ini_data("test_analysysdata","url")
username=r.read_ini_data("test_analysysdata","username")
password=r.read_ini_data("test_analysysdata","password")

#登录ea并且进入到角色与成员界面
class Ea_login(BasePage):
    @classmethod
    def setUpClass(cls) -> None:
        driver=webdriver.Chrome()
        BasePage.set_driver(driver)
        BasePage.max()
        ea=BasePage.get_driver()
        ea.get(url)
        elem1=BasePage.search_elem(['XPATH',Analysysdata_elem.login_btn])
        BasePage.click(elem1)
        #等待login_text元素出现
        WebDriverWait(ea, 2).until(lambda _: ea.find_element(By.XPATH,Analysysdata_elem.login_text))
    @classmethod
    def tearDownClass(cls) -> None:
        sleep(2)
    def test_login(self):
        #登录ea
        ea = BasePage.get_driver()
        elem2=BasePage.search_elem(['XPATH',Analysysdata_elem.account_num_input])
        BasePage.sendkeys(elem2,username)
        elem3=BasePage.search_elem(['XPATH',Analysysdata_elem.password_input])
        BasePage.sendkeys(elem3,password)
        elem4=BasePage.search_elem(['XPATH',Analysysdata_elem.uba_login_btn])
        BasePage.click(elem4)
        #等待ea_operate方舟智能运营元素出现
        WebDriverWait(ea, 3).until(lambda _: ea.find_element(By.XPATH,Analysysdata_elem.ea_operate))
        #进入角色与成员页面


if __name__ == '__main__':
    unittest.main()


























































